<?php

declare(strict_types=1);

namespace Dreamcat\Class2Array\Cases;

use Dreamcat\Class2Array\DemoClass\Pojo2;
use Dreamcat\Class2Array\Impl\DefaultJsonValueFixer;
use PHPUnit\Framework\TestCase;
use stdClass;

/**
 * 测试未定义的情况下的序列化
 * @author vijay
 */
class UndefineTest extends TestCase
{
    /**
     * 测试未定义的情况
     * @return void
     */
    public function testUndefine()
    {
        $fixer = new DefaultJsonValueFixer();
        $fixer->setIgnoreUninit(true);
        $obj = new Pojo2();
        $obj->v1 = uniqid("384");
        $value = $fixer->fixValue($obj);
        self::assertEquals(["v1" => $obj->v1], $value);

        $obj = new Pojo2();
        $value = $fixer->fixValue($obj);
        self::assertEquals(new stdClass(), $value);
    }
}

# end of file
